﻿using System;
using System.Collections.Generic;
using BusinessLogicLibrary.BookingModule;
using BusinessLogicLibrary.CustomerModule;
using BusinessLogicLibrary.SearchModule;
using BusinessLogicLibrary.RoomModule;
using entities;

namespace ServiceLibrary
{
    public class InternalService : IInternalService
    {
        private readonly BookingManagement _bookingManagement;
        private readonly CustomerManament _customerManagement;
        private readonly RoomManagement _roomManagement;
        private readonly Search _search;

        public InternalService()
        {
            _bookingManagement = new BookingManagement();
            _customerManagement = new CustomerManament();
            _roomManagement = new RoomManagement();
            _search = new Search();
        }

        #region"CUSTOMER Management"

        public List<Customer> CusReadAll()
        {
            return _customerManagement.ReadAllCustomer();
        }

        
        public string CusAdd(string pIdentityNumber, string pCustomerName, string pCustomerPhone, string pCustomerEmail,bool pCustomerSex)
        {
            return _customerManagement.CreateCustomer(pIdentityNumber, pCustomerName, pCustomerPhone, pCustomerEmail,pCustomerSex);
        }

        public string CusModify(string pIdentityNumber, string pCustomerName, string pCustomerPhone, string pCustomerEmail,
                              bool pCustomerSex)
        {
            return _customerManagement.EditCustomer(pIdentityNumber, pCustomerName, pCustomerPhone, pCustomerEmail,
                                                    pCustomerSex);
        }

        public string UpdateUserPW(string pUN, string pPW)
        {
            return _customerManagement.UpdateUserPW(pUN, pPW);
        }

        public List<Customer> FindCustomerByName(string pCustomerName)
        {
            return _customerManagement.FindCustomerByName(pCustomerName);
        }

        public Customer FindCustomerByAccount(string pCustomerAccount)
        {
            return _customerManagement.FindCustomerByAccount(pCustomerAccount);
        }

        public Customer FindCustomerByIdentityNumber(string pIdentityNumber)
        {
            return _customerManagement.FindCustomerByID(pIdentityNumber);
        }

        public Customer FindCustomerByEmail(string pEmail)
        {
            return _customerManagement.FindExtUserByEmail(pEmail);
        }

        public bool CusEmailCheck(string email)
        {
            return _customerManagement.CustomerEmailCheck(email);
        }

        public bool CusIdCheck(string id)
        {
            return _customerManagement.CustomerIdCheck(id);
        }

        #endregion

        #region "SEARCH Room for Booking"

        public List<RoomType> SearchByPrice(int minPrice, int maxPrice)
        {
            return _search.SearchByPrice(minPrice, maxPrice);
        }

        public List<RoomType> SearchByFeature(bool view, bool bath, bool balcony)
        {
            return _search.SearchByFeature(view, bath, balcony);
        }

        public List<RoomType> SearchByAll(int minPrice, int maxPrice, bool view, bool bath, bool balcony)
        {
            return _search.SearchByAll(minPrice, maxPrice, view, bath, balcony);
        }

        public List<vRoomInfo> getAvailableRoom(int roomTypeId, DateTime inDate, DateTime outDate)
        {
            return _search.getAvailableRoom(roomTypeId, inDate, outDate);
        }
        
        public List<int> getAvailableRoomID(int roomTypeId, DateTime inDate, DateTime outDate)
        {
            return _search.getAvailableRoomID(roomTypeId, inDate, outDate);
        }

        #endregion

        #region "Booking Management"

        public string BookAdd(string pCustomerID, List<int> pRoomID, DateTime pCheckInDate, DateTime pCheckOutDate)
        {
            return _bookingManagement.CreateBooking(pCustomerID, pRoomID, pCheckInDate, pCheckOutDate);
        }

        #endregion

        #region "ROOM Management"
        public List<RoomType> RoTyGet()
        {
            return _roomManagement.GetRoomType();
        }
        #endregion
    }
}